<?php
/**
 * @copyright meila.com
 * @author shaopu@
 * @name 
 * @param 
 *         $xxx = 作用
 * @static 
 *         XXX = 作用
 * 
 * 
 */
$dir = dirname(__FILE__);
include($dir.'/__queue_global.php');

class ml_mq_sendmail extends MqClass{
    const QUEUE_NAME = ML_QUEUENAME_SENDMAIL;

    /**
     * 发邮件
     *
     * @param array $message_data
     * array(
     *        to => xxx@xxx.com
     *        type => register
     *        data => array(
     *        )
     * )
     */
    public function run_job(){
        $arr = $this->src_data;
        $data['url'] = $arr['url'];
        $data['nick'] = $arr['nick'];
        
        if($arr['type'] == 'findPwd') {
            $tmp_name = 'findpwd';
        }else {
            $tmp_name = 'actMail';
        }
        
        $content = ml_tool_template::parseModTpl($data, $tmp_name);
        $rs = ml_tool_sendmail::sendMessage(ML_SMTP_SENDER_MAIL , ML_SMTP_SENDER_NAME , $arr['email'] , $arr['nick'] , $arr['title'] , $content);
        Tool_logger::dataLog('sendmail_result' , implode("\n" , $rs)."\n\n");
        return true;
    }

}

ml_run_queue_check(ml_mq_sendmail::QUEUE_NAME);

$xblog_obj = new ml_mq_sendmail(new McQueue(ml_mq_sendmail::QUEUE_NAME));
$argv[1]   = __FILE__;
$xblog_obj->setArgv($argv[1]);
$xblog_obj->execute();
?>